home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / March 96 / Re extensions&odf (for ODF tea < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  3.3 KB  |  [TEXT/ttxt]

  1. Subject:     Re: extensions&odf (for ODF team)
  2. Sent:        3/4/96 6:52 PM
  3. Received:    3/4/96 6:20 PM
  4. From:        Greg Friedman, friedman@cognosis.com
  5. Reply-To:    ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. Bernhard S. Wieser wrote:
  9.  
  10. >So, let's see if this is acceptable to y'all ODF gurus...
  11. >
  12. >- I wrapped my sohproperty SOM thing in a derived ODExtension, call it XYZ
  13. >- I inserted the ...HasExtension, ...AcquireExtension, and ...Release
  14.  
  15. Damon and Jim have already explained that ODF provides an extension manager
  16. class to simplify supporting the extension protocols.  There are a couple
  17. of bugs in the d11 implementation of the extension manager, and a couple of
  18. non-obvious things you need to do in your extension.
  19.  
  20. In ODF d11, FW_CExtensionManager::AcquireExtension incorrectly increments
  21. the reference count of every extension it returns. d11 also doesn't return
  22. the correct error if an extension that cannot be provided is requested. The
  23. corrected implementation of AcquireExtension is as follows:
  24.  
  25. ODExtension* FW_CExtensionManager::AcquireExtension(Environment *ev, const
  26. char* name)
  27. {
  28.         ODExtension* theExtension = (ODExtension
  29. *)fActiveExtensions.ValueAtKey(name);
  30.  
  31.         if (!theExtension)
  32.         {
  33.                 CreateExtensionFunc func =
  34. (CreateExtensionFunc)fNameToCreateFuncMap.ValueAtKey(name);
  35.                 if (func)
  36.                 {
  37.                         theExtension = (func)(ev, fPart, name);
  38.                         if (theExtension)
  39.                                 fActiveExtensions.AddPair(name,
  40. (void*)theExtension);
  41.                 }
  42.         }
  43.         else
  44.                 theExtension->Acquire(ev);
  45.  
  46.         if (!theExtension)
  47.                 FW_SetEvError(ev, kODErrUnsupportedExtension);
  48.  
  49.         return theExtension;
  50. }
  51.  
  52. FW_CExtensionManager::ReleaseExtension also needs to return an environment
  53. error of kODErrUnsupportedExtension if the extension* wasn't provided by
  54. the part.
  55.  
  56. When ODPart::ReleaseAll is called the BaseRemoved method of any existing
  57. extensions needs to be called. d11 does not implement this. It is fully
  58. implemented in ODF 1.
  59.  
  60. Notes on implementing extensions:
  61.  
  62. Make sure your extension has a uniquely named Init method. From your
  63. extension's Init method, be sure you call ODExtension::InitExtension. This
  64. will guarantee that your newly created extension begins life with a
  65. correctly initialized reference count.
  66.  
  67. Make sure all of your extensions public methods call the IsValid method
  68. they inherit from ODExtension before attempting to do anything that
  69. requires referencing their base.
  70.  
  71. ODExtension implements release as follows:
  72.         Call the inherited ODRefCntObject::Release method. This will
  73. decrement the ref count
  74.  
  75.        If the base object is valid, and the refCount is zero, call the
  76. ReleaseExtension method of the base
  77.  
  78. This mechanism does not automatically dispose the extension when the
  79. reference count drops to zero. Furthermore, it doesn't handle the case
  80. where your base has been removed and a release causes the extension's
  81. reference count to drop to zero. You will need to override Release in your
  82. extension to implement this functionality.
  83.  
  84. Hope this helps...
  85.  
  86. Greg Friedman
  87.  
  88.  
  89. ___________________________________________________________
  90.   Greg Friedman                      ODF Engineering
  91. Apple Computer
  92.  
  93.